package com.yxt.ui;

import java.io.File;

import com.yxt.common.sys.CommConstant;
import com.yxt.common.ui.ActivityStackControlUtil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;  
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;

public class SystemHelpActivity extends Activity {
	private WebView webHelp;
	
	private void initComponent(){
		Button btnBackHome = (Button)findViewById(R.id.btnBackHome);
		webHelp = (WebView)findViewById(R.id.webHelp);
		btnBackHome.setOnClickListener(new OnClickListener(){
			public void onClick(View arg0) {
				Intent intent = new Intent();
				intent.setClass(getApplicationContext(), MainActivity.class);
				startActivity(intent);
			}
		});
		webHelp.getSettings().setJavaScriptEnabled(true);   
		String help = CommConstant.Config.DEFAULT_PHONE_DIR + CommConstant.Config.HELP_LOCATION;
		File file = new File(help);
		if (file.exists()) {		
			webHelp.loadUrl("content://com.android.htmlfileprovider"+help); 
		} else {
			webHelp.loadUrl(CommConstant.Config.ERROR_FILE_LOCATION); 				
		}
	}
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
		setContentView(R.layout.system_help);   //软件activity的布局	
		ActivityStackControlUtil.add(this);
		initComponent();
	}

	protected void onDestroy() {
		super.onDestroy();
        ActivityStackControlUtil.remove(this);
	}
}